//package com.ttg.web.service.job.primitive.impl;
//
//import com.ttg.common.dto.PrimitiveBaseDTO;
//import com.ttg.common.enums.BankPublicTradeEnum;
//import com.ttg.common.utils.DateTimeUtil;
//import com.ttg.common.vo.TaskResultVO;
//import com.ttg.model.pojo.BankPublicMerchTradePrimitive;
//import com.ttg.model.pojo.BankPublicTradePrimitive;
//import com.ttg.web.dao.BankPublicMerchTradePrimitiveDao;
//import com.ttg.web.service.job.JobCommon;
//import com.ttg.web.service.job.primitive.TradePrimitiveService;
//import org.apache.commons.lang3.StringUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//
//import java.math.BigDecimal;
//import java.time.LocalDate;
//import java.util.ArrayList;
//import java.util.Arrays;
//import java.util.List;
//
///**
// * Description：
// * Author: chenyou
// * Date: 2025/10/15 15:41
// * Company: ttg
// * Copyright: Copyright (c) 2025
// */
//@Service
//public class TradePrimitiveServiceImpl extends JobCommon implements TradePrimitiveService {
//
//    @Autowired
//    private BankPublicMerchTradePrimitiveDao tradePrimitiveDao;
//
//    @Override
//    public TaskResultVO tradePrimitive(PrimitiveBaseDTO reqDto) {
//        //每日定时从晋享e付,数仓获取商户原始数据
//        //todo sftp拉取过程
//        List<BankPublicMerchTradePrimitive> tradePrimitives = getAllMerchTradePrimitive(Integer.parseInt(reqDto.getDate()));
//
//        //交易金额
//        List<BankPublicTradePrimitive> list_101 = tradePrimitives(tradePrimitives,BankPublicTradeEnum.TRADE_AMOUNT);
//        //手续费金额
//        List<BankPublicTradePrimitive> list_201 = tradePrimitives(tradePrimitives,BankPublicTradeEnum.TRADE_CHARGE);
//        //补贴金额
//        List<BankPublicTradePrimitive> list_301 = tradePrimitives(tradePrimitives,BankPublicTradeEnum.TRADE_SUBSIDY);
//        //结算账户每日余额
//        List<BankPublicTradePrimitive> list_401 = tradePrimitives(tradePrimitives,BankPublicTradeEnum.TRADE_BAL_AMOUNT);
//        //交易笔数
//        List<BankPublicTradePrimitive> list_102 = tradePrimitives(tradePrimitives,BankPublicTradeEnum.TRADE_NUMBER);
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
////        tradePrimitiveDao.deleteByDays(Arrays.asList(
////                20250601,20250602,20250603,20250604,20250605,20250606,20250607,20250608
////                ,20250701,20250702,20250703,20250704,2025070,20250706,20250707,20250708
////                ,20250801,20250802,20250803,20250804,20250805,20250806,20250807,20250808));
////        tradePrimitiveDao.saveBatch(tradePrimitives);
//        return null;
//    }
//
//    public List<BankPublicTradePrimitive> tradePrimitives(List<BankPublicMerchTradePrimitive> tradePrimitives, BankPublicTradeEnum tradeEnum){
//        List<BankPublicTradePrimitive> list = new ArrayList<>();
//        for(BankPublicMerchTradePrimitive primitive:tradePrimitives){
//            BankPublicTradePrimitive tradePrimitive = new BankPublicTradePrimitive();
//            tradePrimitive.setMctNo(primitive.getMctNo());
//            tradePrimitive.setTradeType(tradeEnum.getType());
//            tradePrimitive.setUpdateTime(DateTimeUtil.parseYYYYMMDD(String.valueOf(primitive.getTradeDate())));
//            switch (tradeEnum){
//                case TRADE_AMOUNT:
//                    tradePrimitive.setTodayAmount(primitive.getTradeAmt());
//                    break;
//                case TRADE_NUMBER:
//                    tradePrimitive.setTodayAmount(new BigDecimal(primitive.getTradeCount()));
//                    break;
//                case TRADE_CHARGE:
//                    tradePrimitive.setTodayAmount(primitive.getFeeAmt());
//                    break;
//                case TRADE_SUBSIDY:
//                    tradePrimitive.setTodayAmount(primitive.getRepairAmt());
//                    break;
//                case TRADE_BAL_AMOUNT:
//                    tradePrimitive.setTodayAmount(primitive.getBalAmt());
//                    break;
//            }
//            list.add(tradePrimitive);
//        }
//        return list;
//    }
//
//
//
//
//
//
//    public void addTestData(){
//        List<BankPublicMerchTradePrimitive> tradePrimitives = new ArrayList<>();
//        List<Integer> days = new ArrayList<>();
//        LocalDate date = LocalDate.of(2025,6,1);
//        int dateInt = Integer.parseInt(DateTimeUtil.formatDateYYYYMMDD(date));
//        for(int i=0;i<30;i++){
//            int day = Integer.valueOf(dateInt + StringUtils.leftPad(""+i,2,"0"));
//            days.add(day);
//            List<BankPublicMerchTradePrimitive> tradePrimitives1 = getAllMerchTradePrimitive(day);
//            tradePrimitives.addAll(tradePrimitives1);
//        }
//
//        date = LocalDate.of(2025,7,1);
//        dateInt = Integer.parseInt(DateTimeUtil.formatDateYYYYMMDD(date));
//        for(int i=0;i<30;i++){
//            int day = Integer.valueOf(dateInt + StringUtils.leftPad(""+i,2,"0"));
//            days.add(day);
//            List<BankPublicMerchTradePrimitive> tradePrimitives1 = getAllMerchTradePrimitive(day);
//            tradePrimitives.addAll(tradePrimitives1);
//        }
//
//        date = LocalDate.of(2025,8,1);
//        dateInt = Integer.parseInt(DateTimeUtil.formatDateYYYYMMDD(date));
//        for(int i=0;i<30;i++){
//            int day = Integer.valueOf(dateInt + StringUtils.leftPad(""+i,2,"0"));
//            days.add(day);
//            List<BankPublicMerchTradePrimitive> tradePrimitives1 = getAllMerchTradePrimitive(day);
//            tradePrimitives.addAll(tradePrimitives1);
//        }
//
//        tradePrimitiveDao.deleteByDays(days);
//        tradePrimitiveDao.saveBatch(tradePrimitives);
//    }
//
////    public List<BankPublicMerchTradePrimitive> testPrimitives(int date){
////        List<BankPublicMerchTradePrimitive> tradePrimitives = new ArrayList<>();
////        List<BankPublicMerchTradePrimitive> tradePrimitives1 = getAllMerchTradePrimitive(20250601);
////        List<BankPublicMerchTradePrimitive> tradePrimitives2 = getAllMerchTradePrimitive(20250602);
////        List<BankPublicMerchTradePrimitive> tradePrimitives3 = getAllMerchTradePrimitive(20250603);
////        List<BankPublicMerchTradePrimitive> tradePrimitives4 = getAllMerchTradePrimitive(20250604);
////        List<BankPublicMerchTradePrimitive> tradePrimitives5 = getAllMerchTradePrimitive(20250605);
////        List<BankPublicMerchTradePrimitive> tradePrimitives6 = getAllMerchTradePrimitive(20250606);
////        List<BankPublicMerchTradePrimitive> tradePrimitives7 = getAllMerchTradePrimitive(20250607);
////        List<BankPublicMerchTradePrimitive> tradePrimitives8 = getAllMerchTradePrimitive(20250608);
////
////        List<BankPublicMerchTradePrimitive> tradePrimitives9 = getAllMerchTradePrimitive(20250701);
////        List<BankPublicMerchTradePrimitive> tradePrimitives10 = getAllMerchTradePrimitive(20250702);
////        List<BankPublicMerchTradePrimitive> tradePrimitives11 = getAllMerchTradePrimitive(20250703);
////        List<BankPublicMerchTradePrimitive> tradePrimitives12 = getAllMerchTradePrimitive(20250704);
////        List<BankPublicMerchTradePrimitive> tradePrimitives13 = getAllMerchTradePrimitive(20250705);
////        List<BankPublicMerchTradePrimitive> tradePrimitives14 = getAllMerchTradePrimitive(20250706);
////        List<BankPublicMerchTradePrimitive> tradePrimitives15 = getAllMerchTradePrimitive(20250707);
////        List<BankPublicMerchTradePrimitive> tradePrimitives16 = getAllMerchTradePrimitive(20250708);
////
////        List<BankPublicMerchTradePrimitive> tradePrimitives17 = getAllMerchTradePrimitive(20250801);
////        List<BankPublicMerchTradePrimitive> tradePrimitives18 = getAllMerchTradePrimitive(20250802);
////        List<BankPublicMerchTradePrimitive> tradePrimitives19 = getAllMerchTradePrimitive(20250803);
////        List<BankPublicMerchTradePrimitive> tradePrimitives20 = getAllMerchTradePrimitive(20250804);
////        List<BankPublicMerchTradePrimitive> tradePrimitives21 = getAllMerchTradePrimitive(20250805);
////        List<BankPublicMerchTradePrimitive> tradePrimitives22 = getAllMerchTradePrimitive(20250806);
////        List<BankPublicMerchTradePrimitive> tradePrimitives23 = getAllMerchTradePrimitive(20250807);
////        List<BankPublicMerchTradePrimitive> tradePrimitives24 = getAllMerchTradePrimitive(20250808);
////
////        tradePrimitives.addAll(tradePrimitives1);
////        tradePrimitives.addAll(tradePrimitives2);
////        tradePrimitives.addAll(tradePrimitives3);
////        tradePrimitives.addAll(tradePrimitives4);
////        tradePrimitives.addAll(tradePrimitives5);
////        tradePrimitives.addAll(tradePrimitives6);
////        tradePrimitives.addAll(tradePrimitives7);
////        tradePrimitives.addAll(tradePrimitives8);
////        tradePrimitives.addAll(tradePrimitives9);
////        tradePrimitives.addAll(tradePrimitives10);
////        tradePrimitives.addAll(tradePrimitives11);
////        tradePrimitives.addAll(tradePrimitives12);
////        tradePrimitives.addAll(tradePrimitives13);
////        tradePrimitives.addAll(tradePrimitives14);
////        tradePrimitives.addAll(tradePrimitives15);
////        tradePrimitives.addAll(tradePrimitives16);
////        tradePrimitives.addAll(tradePrimitives17);
////        tradePrimitives.addAll(tradePrimitives18);
////        tradePrimitives.addAll(tradePrimitives19);
////        tradePrimitives.addAll(tradePrimitives20);
////        tradePrimitives.addAll(tradePrimitives21);
////        tradePrimitives.addAll(tradePrimitives22);
////        tradePrimitives.addAll(tradePrimitives23);
////        tradePrimitives.addAll(tradePrimitives24);
////        return tradePrimitives;
////    }
//}
